/*
 * IJA2011, Board game "Clovece nezlob se"
 * grp108
 * Tomáš Mičiak,xmicia00
 * Andrej Martinák, xmarti51
 *
 */

package src.clovece;

import java.util.Random;
import java.util.TimerTask;
import src.clovece.game.GameManagement;

/**
 *  Class handling animation representing die throw
 */
public class ThrowDie extends TimerTask {
    private GameManagement gm = GameManagement.getGameManagementInstance();
    private Die die = null;
    private int count = 6;

    public ThrowDie() {
        super();
        this.die = this.gm.getInfoPanel().getDie();
    }

    @Override
    public void run() {
        Random rg = new Random();
        if(count > 0){
            count --;
            int num1 = rg.nextInt(6);
            this.die.repaintDie(num1);
        }
        else{
            gm.dieThrown();
            this.cancel();
        }

    }

}
